<template>
	<input :value='value' :type='type' :maxlength="-1" :placeholder='placeholder' :placeholder-class='placeholderClass' :placeholder-style='placeholderStyle' @input='handleInput' @blur='handleBlur'>
</template>

<script>
	export default {
		props: {
			value: [String,Number],
			type: {
				type: String,
				default: 'text'
			},
			placeholder: {
				type: String,
				default: '请输入'
			},
			placeholderClass: String,
			placeholderStyle: String,
			maxlength: {
				type: Number,
				default: 140
			}
		},
		methods: {
			handleInput(e) {
				this.$emit('input',e.detail.value)
			},
			handleBlur() {
				if(this.maxlength != -1 && this.value.length >= this.maxlength) {
					let newText = this.value.substring(0,this.maxlength)
					this.$emit('input',newText)
				} else {
					this.$emit('input',this.value)
				}
				this.$emit('blur')
			}
		}
	}
</script>

<style>
</style>